package com.shiku.mianshi.controller;

import cn.xyz.commons.utils.ReqUtil;
import cn.xyz.commons.vo.JSONMessage;
import cn.xyz.mianshi.utils.SKBeanUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(value="DigitalCurrencyController",tags="数字货币")
@RequestMapping(value = "/wallet")
public class DigitalCurrencyController  extends AbstractController {

    @ApiOperation("添加数字货币")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query" , name="currencyName" , value="货币名称",dataType="String",required=true,defaultValue = ""),
            @ApiImplicitParam(paramType="query" , name="currencyIcon" , value="货币图标",dataType="String",defaultValue = "")
    })
    @RequestMapping(value = "/addcurrency",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage addCurrencyInfo(@RequestParam(defaultValue="") String currencyName,@RequestParam(defaultValue="") String currencyIcon)
    {
       SKBeanUtils.getDigitalCurrencyManager().addCurrencyInfo(currencyName,currencyIcon);
        return JSONMessage.success();
    }
    @ApiOperation("获取数字货币列表")
    @RequestMapping(value = "/list",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage getCurrencyList()
    {
        Integer userId = ReqUtil.getUserId();
        Object _obj = SKBeanUtils.getDigitalCurrencyManager().getDigitalCurrencyList(userId);
        return JSONMessage.success(_obj);
    }
    @ApiOperation("获取数字货币拥有金额列表")
    @RequestMapping(value = "/walletlist",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage getWalletCurrencyList()
    {
        Integer userId = ReqUtil.getUserId();
        Object _obj = SKBeanUtils.getDigitalCurrencyManager().getDigitalCurrencyScoreList(userId);
        return JSONMessage.success(_obj);
    }

    @ApiOperation("关注数字货币")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "id" ,dataType = "String")
    })
    @RequestMapping(value = "/addfollow",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage addFollow(@RequestParam(defaultValue="") String id)
    {
        Integer userId = ReqUtil.getUserId();
        SKBeanUtils.getDigitalCurrencyManager().addCurrencyFollow(id,userId);
        return JSONMessage.success();
    }
    @ApiOperation("取消关注数字货币")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value = "id" ,dataType = "String")
    })
    @RequestMapping(value = "/delfollow",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage delFollow(@RequestParam(defaultValue="") String id)
    {
        Integer userId = ReqUtil.getUserId();
        SKBeanUtils.getDigitalCurrencyManager().delCurrencyFollow(id,userId);
        return JSONMessage.success();
    }

    @ApiOperation("获取关注数字货币列表")
    @RequestMapping(value = "/getfollowlist",method = {RequestMethod.POST,RequestMethod.GET})
    public JSONMessage getFollowList()
    {
        Integer userId = ReqUtil.getUserId();
        Object _obj = SKBeanUtils.getDigitalCurrencyManager().getFollowList(userId);
        return JSONMessage.success(_obj);
    }


}
